package com.attilax.asyn;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

import com.attilax.core;

public class AsynUtil {

	/**
	@author attilax 老哇的爪子
		@since  o8s 0_g_l   
	
	 */
	public static void execMeth_Ays(final Runnable runnable, final String threadName) {
		// attilax 老哇的爪子  0_g_l   o8s 
		try {
			newThread(runnable,threadName);
		} catch (Exception e) {
			core.err(e);
		}
		
	}
	
	public static Thread newThread(final Runnable runnable, final String threadName) {
		return	new com.attilax.tryX<Thread>() {
				@Override public Thread $$(Object t) throws Exception {
					// attilax 老哇的爪子 h_i_r o7n

					Thread Thread_ini_fentsiController = new Thread(runnable);
					Thread_ini_fentsiController.setName(threadName);
					Thread_ini_fentsiController.setPriority(Thread.MAX_PRIORITY);
					Thread_ini_fentsiController.start();
					// System.out.println("--thrd:"+threadName);
					return Thread_ini_fentsiController;
				}
			}.$(new Thread());
			
		
		}
	public static void exe(FutureTask futTask) {
		ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
		newSingleThreadExecutor.submit(futTask);
		
		newSingleThreadExecutor.shutdown();
		
	}
 

}
